<?php

function OutputError($message)
{
   print("ERROR\n");
   print($message);
}

function OutputMessage($sender, $time, $message)
{
   $gen = GenRandomString(10);
   print("MESSAGE $sender" . "_$gen\n");
   print("$time\n");
   print("$message\n");
   print("END $sender_$gen\n");
}

function GenRandomString($length) {
    $characters = "0123456789abcdefghijklmnopqrstuvwxyz";
    $string = "";    
    for ($p = 0; $p < $length; $p++) {
        $string .= $characters[mt_rand(0, strlen($characters))];
    }
    return $string;
}
?>